#include <stdio.h>


int longestValidParentheses(char * s);

int main(int argc,char **argv)
{


	printf("%d\n",longestValidParentheses(*(argv+1)));
	return 0;
}





int longestValidParentheses(char * s){


	char *pstr=s;

	int leftC=0,rightC=0;

	int newW=0,lastW=0;

	while(*pstr)
	{
	
		if(*pstr=='(')
		{
			leftC++;
		
		}

		else if(*pstr==')')
		{
			
			rightC++;
			
			if(rightC>leftC)
			{

				newW=rightC;
	


				rightC=0;
				leftC=0;	
			
			}

		}
	
	
		pstr++;
	}

}
